#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    vector<string> ret;
    string path;
    string vs[10];
    vector<string> letterCombinations(string digits) {
        if (digits.size() == 0) return ret;
        char ch = 'a';
        for (int i = 2; i <= 9; i++)
        {
            int n = 3;
            if (i == 7 || i == 9) n++;
            for (int j = 0; j < n; j++) vs[i].push_back(ch++);
        }
        int pos = 0;
        dfs(digits, pos);
        return ret;
    }
    void dfs(string digits, int pos)
    {
        if (pos == digits.size())
        {
            ret.push_back(path);
            return;
        }
        int n = digits[pos] - '0';
        for (int i = 0; i < vs[n].size(); i++)
        {
            path.push_back(vs[n][i]);
            dfs(digits, pos + 1);
            path.pop_back();
        }
    }
};